ActiveReports 11
PDF Print Presets
ActiveReports 11 > ActiveReports User Guide > How To > Print > PDF Print Presets

To economize your efforts each time a PDF document is printed, you can preset basic print options when exporting a report to a PDF format.

Note: The print preset properties are only available with the Professional Edition license. An evaluation message is displayed when used with the Standard Edition license.

In both Page/RDL and Section reports, you can set the PDF Print Preset properties using the Export dialog or through the code. The PDF print preset properties are available in the Export dialog of the following viewers.

To set PDF print presets using the Export dialog

 

  1. Open the Export dialog.
  2. In the Export Format field of the Export dialog, select Portable Document Format (PDF).

  3. Expand PrintPresets options and set the required properties for print presets.
    Note: These properties are available in PDF version 1.7 or higher. The PageScaling property is supported in PDF version 1.6.
  4. Click OK to close the dialog.

To set PDF print presets through code

  1. From the Visual Studio File menu, select New, then Project.
  2. In the New Project dialog that appears, under language VB.NET or C#, click the Reporting node.
  3. Select the type of report application that you want to add:
    • ActiveReports 11 Page Report Application
    • ActiveReports 11 RDL Report Application
    • ActiveReports 11 Section Report Application (xml-based)
  4. In the Name field, enter a name for the report application, and click OK. The selected report type is added to your project.
  5. In the Design view, double-click the Form title bar to create the Form_Load event.
  6. Add the following code to invoke the Export methods and set print presets in the Form_Load event.

    Section Report

    Visual Basic.NET code. Paste INSIDE the Form_Load event
    Copy Code
    Dim sectionReport As New GrapeCity.ActiveReports.SectionReport()
    Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\..\..\SectionReport1.rpx")
    sectionReport.LoadLayout(xtr)
    sectionReport.Run()
    
    'Define settings for PDF
    Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport()
    p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17
    
    'Set default print settings using PrintPresets class
    p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None
    p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge
    p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two
    p.PrintPresets.PaperSourceByPageSize = True
    p.PrintPresets.PrintPageRange = "1-3"
    p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf")
    

     

    C# code. Paste INSIDE the Form_Load event
    Copy Code
    GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport();
    System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx");
    sectionReport.LoadLayout(xtr);
    sectionReport.Run();
    
    //Define settings for PDF
    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
    p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17;
    
    //Set default print settings using PrintPresets class
    p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None;
    p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge;
    p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two;
    p.PrintPresets.PaperSourceByPageSize = true;
    p.PrintPresets.PrintPageRange = "1-3";
    p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf");
    

    Page/RDL Report

    Visual Basic.NET code. Paste INSIDE the Form_Load event
    Copy Code
    'Set the rendering extension and render the report.
    Dim pdfExport = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()
    
    'Define settings for PDF
    Dim pdfSettings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()
    pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17
    pdfSettings.PrintOnOpen = True
    
    'Set default print settings using PrintPresets class
    Dim pdfPresetsSetting As New GrapeCity.ActiveReports.Export.Pdf.PrintPresets()
    pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None
    pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge
    pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two
    pdfPresetsSetting.PaperSourceByPageSize = True
    pdfPresetsSetting.PrintPageRange = "1-3"
    
    pdfSettings.PrintPresets = pdfPresetsSetting
    
    Dim outputFile = New IO.FileInfo("..\..\PrintPresets.pdf")
    Dim reportFile = New IO.FileInfo("..\..\PageReport1.rdlx")
    
    Dim fileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory, Path.GetFileNameWithoutExtension(outputFile.FullName))
    
    Using pageDocument = New GrapeCity.ActiveReports.PageReport(reportFile).Document
        pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings)
    End Using
    
    C# code. Paste INSIDE the Form_Load event
    Copy Code
    //Set the rendering extension and render the report.
    var pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
    
    //Define settings for PDF
    GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSettings = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
    pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17;
    pdfSettings.PrintOnOpen = true;
    
    //Set default print settings using PrintPresets class
    GrapeCity.ActiveReports.Export.Pdf.PrintPresets pdfPresetsSetting = new GrapeCity.ActiveReports.Export.Pdf.PrintPresets();
    pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None;
    pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge;
    pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two;
    pdfPresetsSetting.PaperSourceByPageSize = true;
    pdfPresetsSetting.PrintPageRange = "1-3";
    
    pdfSettings.PrintPresets = pdfPresetsSetting;
    
    var outputFile = new System.IO.FileInfo(@"..\..\PrintPresets.pdf");
    var reportFile = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
    
    var fileStreamProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory,
    System.IO.Path.GetFileNameWithoutExtension(outputFile.FullName));
    
    using (var pageDocument = new GrapeCity.ActiveReports.PageReport(reportFile).Document)
    {
        pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings);
    }
    
See Also